home *** CD-ROM | disk | FTP | other *** search
/ SGI Developer Toolbox 6.1 / SGI Developer Toolbox 6.1 - Disc 4.iso / public / bit / src / jpeg / jconfig.h < prev    next >
C/C++ Source or Header  |  1994-08-01  |  12KB  |  374 lines

  1. /*
  2.  * jconfig.h
  3.  *
  4.  * Copyright (C) 1991, 1992, Thomas G. Lane.
  5.  * This file is part of the Independent JPEG Group's software.
  6.  * For conditions of distribution and use, see the accompanying README file.
  7.  *
  8.  * This file contains preprocessor declarations that help customize
  9.  * the JPEG software for a particular application, machine, or compiler.
  10.  * Edit these declarations as needed (or add -D flags to the Makefile).
  11.  */
  12.  
  13.  
  14. /*
  15.  * These symbols indicate the properties of your machine or compiler.
  16.  * The conditional definitions given may do the right thing already,
  17.  * but you'd best look them over closely, especially if your compiler
  18.  * does not handle full ANSI C.  An ANSI-compliant C compiler should
  19.  * provide all the necessary features; __STDC__ is supposed to be
  20.  * predefined by such compilers.
  21.  */
  22.  
  23. /*
  24.  * HAVE_STDC is tested below to see whether ANSI features are available.
  25.  * We avoid testing __STDC__ directly for arcane reasons of portability.
  26.  * (On some compilers, __STDC__ is only defined if a switch is given,
  27.  * but the switch also disables machine-specific features we need to get at.
  28.  * In that case, -DHAVE_STDC in the Makefile is a convenient solution.)
  29.  */
  30.  
  31. #ifdef __STDC__            /* if compiler claims to be ANSI, believe it */
  32. #define HAVE_STDC
  33. #endif
  34.  
  35.  
  36. /* Does your compiler support function prototypes? */
  37. /* (If not, you also need to use ansi2knr, see SETUP) */
  38.  
  39. #ifdef HAVE_STDC        /* ANSI C compilers always have prototypes */
  40. #define PROTO
  41. #else
  42. #ifdef __cplusplus        /* So do C++ compilers */
  43. #define PROTO
  44. #endif
  45. #endif
  46.  
  47. /* sgi supports prototypes */
  48. #ifndef PROTO
  49. #define PROTO
  50. #endif
  51.  
  52. /* Does your compiler support the declaration "unsigned char" ? */
  53. /* How about "unsigned short" ? */
  54.  
  55. #ifdef HAVE_STDC        /* ANSI C compilers must support both */
  56. #define HAVE_UNSIGNED_CHAR
  57. #define HAVE_UNSIGNED_SHORT
  58. #endif
  59.  
  60. /* sgi supports both */
  61. #ifndef HAVE_UNSIGNED_CHAR
  62. #define HAVE_UNSIGNED_CHAR
  63. #define HAVE_UNSIGNED_SHORT
  64. #endif
  65. /* Define this if an ordinary "char" type is unsigned.
  66.  * If you're not sure, leaving it undefined will work at some cost in speed.
  67.  * If you defined HAVE_UNSIGNED_CHAR then it doesn't matter very much.
  68.  */
  69.  
  70. /* #define CHAR_IS_UNSIGNED */
  71.  
  72. /* Define this if your compiler implements ">>" on signed values as a logical
  73.  * (unsigned) shift; leave it undefined if ">>" is a signed (arithmetic) shift,
  74.  * which is the normal and rational definition.
  75.  */
  76.  
  77. /* #define RIGHT_SHIFT_IS_UNSIGNED */
  78.  
  79. /* Define "void" as "char" if your compiler doesn't know about type void.
  80.  * NOTE: be sure to define void such that "void *" represents the most general
  81.  * pointer type, e.g., that returned by malloc().
  82.  */
  83.  
  84. /* #define void char */
  85.  
  86. /* Define const as empty if your compiler doesn't know the "const" keyword. */
  87. /* (Even if it does, defining const as empty won't break anything.) */
  88.  
  89. #ifndef HAVE_STDC        /* ANSI C and C++ compilers should know it. */
  90. #ifndef __cplusplus
  91. #define Const
  92. #define const
  93. #endif
  94. #endif
  95.  
  96. /* sgi supports const */
  97. #ifdef Const
  98. #undef const
  99. #endif
  100. /* For 80x86 machines, you need to define NEED_FAR_POINTERS,
  101.  * unless you are using a large-data memory model or 80386 flat-memory mode.
  102.  * On less brain-damaged CPUs this symbol must not be defined.
  103.  * (Defining this symbol causes large data structures to be referenced through
  104.  * "far" pointers and to be allocated with a special version of malloc.)
  105.  */
  106.  
  107. #ifdef MSDOS
  108. #define NEED_FAR_POINTERS
  109. #endif
  110.  
  111.  
  112. /* The next three symbols only affect the system-dependent user interface
  113.  * modules (jcmain.c, jdmain.c).  You can ignore these if you are supplying
  114.  * your own user interface code.
  115.  */
  116.  
  117. /* Define this if you want to name both input and output files on the command
  118.  * line, rather than using stdout and optionally stdin.  You MUST do this if
  119.  * your system can't cope with binary I/O to stdin/stdout.  See comments at
  120.  * head of jcmain.c or jdmain.c.
  121.  */
  122.  
  123. #ifdef MSDOS            /* two-file style is needed for PCs */
  124. #ifndef USE_SETMODE        /* unless you have setmode() */
  125. #define TWO_FILE_COMMANDLINE
  126. #endif
  127. #endif
  128. #ifdef THINK_C            /* it's needed for Macintosh too */
  129. #define TWO_FILE_COMMANDLINE
  130. #endif
  131.  
  132. /* Define this if your system needs explicit cleanup of temporary files.
  133.  * This is crucial under MS-DOS, where the temporary "files" may be areas
  134.  * of extended memory; on most other systems it's not as important.
  135.  */
  136.  
  137. #ifdef MSDOS
  138. #define NEED_SIGNAL_CATCHER
  139. #endif
  140.  
  141. /* By default, we open image files with fopen(...,"rb") or fopen(...,"wb").
  142.  * This is necessary on systems that distinguish text files from binary files,
  143.  * and is harmless on most systems that don't.  If you have one of the rare
  144.  * systems that complains about the "b" spec, define this symbol.
  145.  */
  146.  
  147. #define DONT_USE_B_MODE 
  148.  
  149.  
  150. /* If you're getting bored, that's the end of the symbols you HAVE to
  151.  * worry about.  Go fix the makefile and compile.
  152.  */
  153.  
  154.  
  155. /* If your compiler supports inline functions, define INLINE
  156.  * as the inline keyword; otherwise define it as empty.
  157.  */
  158.  
  159. #ifdef __GNUC__            /* for instance, GNU C knows about inline */
  160. #define INLINE __inline__
  161. #endif
  162. #ifndef INLINE            /* default is to define it as empty */
  163. #define INLINE
  164. #endif
  165.  
  166. /* On a few systems, type boolean and/or macros FALSE, TRUE may appear
  167.  * in standard header files.  Or you may have conflicts with application-
  168.  * specific header files that you want to include together with these files.
  169.  * In that case you need only comment out these definitions.
  170.  */
  171.  
  172. typedef int boolean;
  173. #undef FALSE            /* in case these macros already exist */
  174. #undef TRUE
  175. #define FALSE    0        /* values of boolean */
  176. #define TRUE    1
  177.  
  178. /* This defines the size of the I/O buffers for entropy compression
  179.  * and decompression; you could reduce it if memory is tight.
  180.  */
  181.  
  182. #define JPEG_BUF_SIZE    4096 /* bytes */
  183.  
  184.  
  185.  
  186. /* These symbols determine the JPEG functionality supported. */
  187.  
  188. /*
  189.  * These defines indicate whether to include various optional functions.
  190.  * Undefining some of these symbols will produce a smaller but less capable
  191.  * program file.  Note that you can leave certain source files out of the
  192.  * compilation/linking process if you've #undef'd the corresponding symbols.
  193.  * (You may HAVE to do that if your compiler doesn't like null source files.)
  194.  */
  195.  
  196. /* Arithmetic coding is unsupported for legal reasons.  Complaints to IBM. */
  197.  
  198. /* Encoder capability options: */
  199. #undef  C_ARITH_CODING_SUPPORTED    /* Arithmetic coding back end? */
  200. #undef  C_MULTISCAN_FILES_SUPPORTED /* Multiple-scan JPEG files?  (NYI) */
  201. #define ENTROPY_OPT_SUPPORTED        /* Optimization of entropy coding parms? */
  202. #define INPUT_SMOOTHING_SUPPORTED   /* Input image smoothing option? */
  203. /* Decoder capability options: */
  204. #undef  D_ARITH_CODING_SUPPORTED    /* Arithmetic coding back end? */
  205. #define D_MULTISCAN_FILES_SUPPORTED /* Multiple-scan JPEG files? */
  206. #define BLOCK_SMOOTHING_SUPPORTED   /* Block smoothing during decoding? */
  207. #define QUANT_1PASS_SUPPORTED    /* 1-pass color quantization? */
  208. #define QUANT_2PASS_SUPPORTED    /* 2-pass color quantization? */
  209. /* these defines indicate which JPEG file formats are allowed */
  210. #define JFIF_SUPPORTED        /* JFIF or "raw JPEG" files */
  211. #undef  JTIFF_SUPPORTED        /* JPEG-in-TIFF (not yet implemented) */
  212. /* these defines indicate which image (non-JPEG) file formats are allowed */
  213. #define GIF_SUPPORTED        /* GIF image file format */
  214. /* #define RLE_SUPPORTED */    /* RLE image file format (by default, no) */
  215. #define PPM_SUPPORTED        /* PPM/PGM image file format */
  216. #define TARGA_SUPPORTED        /* Targa image file format */
  217. #undef  TIFF_SUPPORTED        /* TIFF image file format (not yet impl.) */
  218.  
  219. /* more capability options later, no doubt */
  220.  
  221.  
  222. /*
  223.  * Define exactly one of these three symbols to indicate whether you want
  224.  * 8-bit, 12-bit, or 16-bit sample (pixel component) values.  8-bit is the
  225.  * default and is nearly always the right thing to use.  You can use 12-bit if
  226.  * you need to support image formats with more than 8 bits of resolution in a
  227.  * color value.  16-bit should only be used for the lossless JPEG mode (not
  228.  * currently supported).  Note that 12- and 16-bit values take up twice as
  229.  * much memory as 8-bit!
  230.  * Note: if you select 12- or 16-bit precision, it is dangerous to turn off
  231.  * ENTROPY_OPT_SUPPORTED.  The standard Huffman tables are only good for 8-bit
  232.  * precision, so jchuff.c normally uses entropy optimization to compute
  233.  * usable tables for higher precision.  If you don't want to do optimization,
  234.  * you'll have to supply different default Huffman tables.
  235.  */
  236.  
  237. #define EIGHT_BIT_SAMPLES
  238. #undef  TWELVE_BIT_SAMPLES
  239. #undef  SIXTEEN_BIT_SAMPLES
  240.  
  241.  
  242.  
  243. /*
  244.  * The remaining definitions don't need to be hand-edited in most cases.
  245.  * You may need to change these if you have a machine with unusual data
  246.  * types; for example, "char" not 8 bits, "short" not 16 bits,
  247.  * or "long" not 32 bits.  We don't care whether "int" is 16 or 32 bits,
  248.  * but it had better be at least 16.
  249.  */
  250.  
  251. /* First define the representation of a single pixel element value. */
  252.  
  253. #ifdef EIGHT_BIT_SAMPLES
  254. /* JSAMPLE should be the smallest type that will hold the values 0..255.
  255.  * You can use a signed char by having GETJSAMPLE mask it with 0xFF.
  256.  * If you have only signed chars, and you are more worried about speed than
  257.  * memory usage, it might be a win to make JSAMPLE be short.
  258.  */
  259.  
  260. #ifdef HAVE_UNSIGNED_CHAR
  261.  
  262. typedef unsigned char JSAMPLE;
  263. #define GETJSAMPLE(value)  (value)
  264.  
  265. #else /* not HAVE_UNSIGNED_CHAR */
  266. #ifdef CHAR_IS_UNSIGNED
  267.  
  268. typedef char JSAMPLE;
  269. #define GETJSAMPLE(value)  (value)
  270.  
  271. #else /* not CHAR_IS_UNSIGNED */
  272.  
  273. typedef char JSAMPLE;
  274. #define GETJSAMPLE(value)  ((value) & 0xFF)
  275.  
  276. #endif /* CHAR_IS_UNSIGNED */
  277. #endif /* HAVE_UNSIGNED_CHAR */
  278.  
  279. #define BITS_IN_JSAMPLE   8
  280. #define MAXJSAMPLE    255
  281. #define CENTERJSAMPLE    128
  282.  
  283. #endif /* EIGHT_BIT_SAMPLES */
  284.  
  285.  
  286. #ifdef TWELVE_BIT_SAMPLES
  287. /* JSAMPLE should be the smallest type that will hold the values 0..4095. */
  288. /* On nearly all machines "short" will do nicely. */
  289.  
  290. typedef short JSAMPLE;
  291. #define GETJSAMPLE(value)  (value)
  292.  
  293. #define BITS_IN_JSAMPLE   12
  294. #define MAXJSAMPLE    4095
  295. #define CENTERJSAMPLE    2048
  296.  
  297. #endif /* TWELVE_BIT_SAMPLES */
  298.  
  299.  
  300. #ifdef SIXTEEN_BIT_SAMPLES
  301. /* JSAMPLE should be the smallest type that will hold the values 0..65535. */
  302.  
  303. #ifdef HAVE_UNSIGNED_SHORT
  304.  
  305. typedef unsigned short JSAMPLE;
  306. #define GETJSAMPLE(value)  (value)
  307.  
  308. #else /* not HAVE_UNSIGNED_SHORT */
  309.  
  310. /* If int is 32 bits this'll be horrendously inefficient storage-wise.
  311.  * But since we don't actually support 16-bit samples (ie lossless coding) yet,
  312.  * I'm not going to worry about making a smarter definition ...
  313.  */
  314. typedef unsigned int JSAMPLE;
  315. #define GETJSAMPLE(value)  (value)
  316.  
  317. #endif /* HAVE_UNSIGNED_SHORT */
  318.  
  319. #define BITS_IN_JSAMPLE    16
  320. #define MAXJSAMPLE    65535
  321. #define CENTERJSAMPLE    32768
  322.  
  323. #endif /* SIXTEEN_BIT_SAMPLES */
  324.  
  325.  
  326. /* Here we define the representation of a DCT frequency coefficient.
  327.  * This should be a signed 16-bit value; "short" is usually right.
  328.  * It's important that this be exactly 16 bits, no more and no less;
  329.  * more will cost you a BIG hit of memory, less will give wrong answers.
  330.  */
  331.  
  332. typedef short JCOEF;
  333.  
  334.  
  335. /* The remaining typedefs are used for various table entries and so forth.
  336.  * They must be at least as wide as specified; but making them too big
  337.  * won't cost a huge amount of memory, so we don't provide special
  338.  * extraction code like we did for JSAMPLE.  (In other words, these
  339.  * typedefs live at a different point on the speed/space tradeoff curve.)
  340.  */
  341.  
  342. /* UINT8 must hold at least the values 0..255. */
  343.  
  344. #ifdef HAVE_UNSIGNED_CHAR
  345. typedef unsigned char UINT8;
  346. #else /* not HAVE_UNSIGNED_CHAR */
  347. #ifdef CHAR_IS_UNSIGNED
  348. typedef char UINT8;
  349. #else /* not CHAR_IS_UNSIGNED */
  350. typedef short UINT8;
  351. #endif /* CHAR_IS_UNSIGNED */
  352. #endif /* HAVE_UNSIGNED_CHAR */
  353.  
  354. /* UINT16 must hold at least the values 0..65535. */
  355.  
  356. #ifdef HAVE_UNSIGNED_SHORT
  357. typedef unsigned short UINT16;
  358. #else /* not HAVE_UNSIGNED_SHORT */
  359. typedef unsigned int UINT16;
  360. #endif /* HAVE_UNSIGNED_SHORT */
  361.  
  362. /* INT16 must hold at least the values -32768..32767. */
  363.  
  364. #ifndef XMD_H            /* X11/xmd.h correctly defines INT16 */
  365. typedef short INT16;
  366. #endif
  367.  
  368. /* INT32 must hold signed 32-bit values; if your machine happens */
  369. /* to have 64-bit longs, you might want to change this. */
  370.  
  371. #ifndef XMD_H            /* X11/xmd.h correctly defines INT32 */
  372. typedef long INT32;
  373. #endif
  374.